import mockjs from "mockjs"
const adminPermission = [
    {
        lable: "首页",
        icon: "HomeFilled",
        name: "home",
        path: "/home",
        componentPath: "views/HomeView.vue"
    },
    {
        lable: "组件",
        icon: "DocumentAdd",
        children: [
            {
                lable: "地图",
                icon: "Compass",
                name: "map",
                path: "/map",
                componentPath: "views/MapView.vue"
            },
            {
                lable: "图标",
                icon: "Coin",
                children: [
                    {
                        lable: "普通图标",
                        icon: "Coin",
                        name: "normalicon",
                        path: "/normalicon",
                        componentPath: "views/NormalIconView.vue"
                    },
                    {
                        lable: "多彩图标",
                        icon: "Coin",
                        name: "color",
                        path: "/color",
                        componentPath: "views/ColorView.vue"
                    }
                ]
            },
        ]
    },
    {
        lable: "商品",
        icon: "ShoppingCartFull",
        children: [
            {
                lable: "商品管理",
                icon: "Goods",
                name: "goodmanage",
                path: "/goodmanage",
                componentPath: "views/ShopView.vue"
            }
        ]
    },
    {
        lable: "错误",
        icon: "Failed",
        children: [
            {
                lable: "401",
                icon: "WarningFilled",
                name: "401",
                path: "/:pathMatch(.*)*",
                componentPath: "views/NotFound.vue"
            },
        ]
    },
]
const userPermission = [
    {
        lable: "首页",
        icon: "HomeFilled",
        name: "home",
        path: "/home",
        componentPath: "views/HomeView.vue"
    },
    {
        lable: "组件",
        icon: "DocumentAdd",
        children: [
            {
                lable: "地图",
                icon: "Compass",
                name: "map",
                path: "/map",
                componentPath: "views/MapView.vue"
            },
            {
                lable: "图标",
                icon: "Coin",
                children: [
                    {
                        lable: "普通图标",
                        icon: "Coin",
                        name: "normalicon",
                        path: "/normalicon",
                        componentPath: "views/NormalIconView.vue"
                    },
                    {
                        lable: "多彩图标",
                        icon: "Coin",
                        name: "color",
                        path: "/color",
                        componentPath: "views/ColorView.vue"
                    }
                ]
            },
        ]
    },
]
mockjs.mock(/\/login/, /post/, function (option) {
    // console.log(option, "option");
    let { username, password } = JSON.parse(option.body)
    console.log(username, password);
    if (username == 'admin' && password == "123456") {
        return {
            code: 0,
            msg: "登陆成功",
            data: {
                token: "admin token",
                userinfo: {
                    head: "",
                    username: "",
                },
                permission: adminPermission
            }
        }
    }
    else if (username == 'gzh' && password == "123456") {
        return {
            code: 0,
            msg: "登陆成功",
            data: {
                token: "gaozihang token",
                userinfo: {
                    head: "",
                    username: "",
                },
                permission: userPermission
            }
        }
    }
    else {
        return {
            code: 1001,
            msg: "用户名密码不匹配",
            data: {

            }
        }
    }
})